home *** CD-ROM | disk | FTP | other *** search
/ Megahits 5 / Megahits 5 (1994)(GTI - Rhein-Main-Soft)(DE)(Disc 2 of 2)[!].iso / archive / show / superview_lib6_3.lha / superview-lib / Programmers / Example_Tools / ControlPad / CPD.c < prev    next >
C/C++ Source or Header  |  1994-06-06  |  6KB  |  201 lines

  1. /* ======================================================================== */
  2. /* = Programmname    : ControlPadDemo V6.1                                = */
  3. /* =                                      = */
  4. /* ======================================================================== */
  5. /* = Author/Copyright : (c) 1993-94 by Andreas Ralph Kleinert.            = */
  6. /* =               Freeware. All rights reserved.              = */
  7. /* =                                      = */
  8. /* =                   Use it as an example for programming               = */
  9. /* =                   superview.library !                                = */
  10. /* =                                      = */
  11. /* ======================================================================== */
  12. /* = Function          : Demonstrates handling and creation of             = */
  13. /* =                standard superview ControlPads                    = */
  14. /* =                with superviewsupport.library.                    = */
  15. /* =                                      = */
  16. /* ======================================================================== */
  17. /* = Last Update      : 27.5.1994                      = */
  18. /* =                                      = */
  19. /* ======================================================================== */
  20. /* = Remarks          : Needs "superview.library" V5+                     = */
  21. /* =                and "superviewsupport.library" V2+.               = */
  22. /* =                                      = */
  23. /* ======================================================================== */
  24. /* = Compiler          : SAS/C V6.51                        = */
  25. /* =                (smakefile)                                       = */
  26. /* ======================================================================== */
  27.  
  28. #include <intuition/intuitionbase.h>
  29.  
  30. #include <superview/superview.h>
  31. #include <superviewsupport/superviewsupport.h>
  32.  
  33. #include <proto/exec.h>
  34. #include <proto/dos.h>
  35. #include <proto/intuition.h>
  36. #include <proto/superview.h>
  37. #include <proto/superviewsupport.h>
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42.  
  43.  
  44.    /* Help- and Info- Texts */
  45.  
  46. char entry1_text  [] = "\2331;32;40mControlPadDemo V6.1 \2330;32;40m\2333;32;40m(FREEWARE)\2330;32;40m\n(c) 1993-94 by Andreas Ralph Kleinert.\nAndreas R. Kleinert, Grube Hohe Grethe 23, D-57074 Siegen, Germany.\n";
  47. char entry2_text  [] = "Tests some superviewsupport.library functions.\n";
  48. char entry3_text  [] = "USAGE : \2330;33;40mControlPadDemo\2330;31;40m\n";
  49.  
  50.  
  51. char ver_text [] = "\0$VER: ControlPadDemo V6.1 (27.5.94)";
  52.  
  53.  
  54. /* *************************************************** */
  55. /* *                             * */
  56. /* * Error-Messages for Leave() and KF_Message()     * */
  57. /* *                             * */
  58. /* *************************************************** */
  59.  
  60. char intuitionlib_text    [] = "You need \42intuition.library\42 V37+ !";
  61. char svlib_text     [] = "You need \42superview.library\42 V5+ !";
  62. char svslib_text     [] = "You need \42superviewsupport.library\42 V2+ !";
  63.  
  64.  
  65. /* *************************************************** */
  66. /* *                             * */
  67. /* * MACROs for Version-Tests                 * */
  68. /* *                             * */
  69. /* *************************************************** */
  70.  
  71. #define LibVer(x) ( ((struct Library *) x)->lib_Version )
  72. #define OS_VER      LibVer(SysBase)
  73.  
  74.  
  75. /* *************************************************** */
  76. /* *                             * */
  77. /* * Function Declarations                 * */
  78. /* *                             * */
  79. /* *************************************************** */
  80.  
  81. void __regargs Load_Test(void);                     /* calls Save_Test, also */
  82. void __regargs Save_Test(struct SV_ControlPad *pad);
  83.  
  84. void __regargs Leave(char *endtext, long code);
  85.  
  86.  
  87.    /* Functions from module "Test_Subs.o" : */
  88.  
  89. extern void __stdargs K_Printf(char *formatstring, ...);
  90.  
  91.  
  92. /* *************************************************** */
  93. /* *                             * */
  94. /* * Additional Base Declarations             * */
  95. /* *                             * */
  96. /* *************************************************** */
  97.  
  98. extern struct ExecBase *SysBase;
  99.  
  100. struct IntuitionBase *IntuitionBase = N;
  101. struct SuperViewBase *SuperViewBase = N;
  102. struct SVSupportBase *SVSupportBase = N;
  103.  
  104.  
  105. /* *************************************************** */
  106. /* *                             * */
  107. /* * MAIN                         * */
  108. /* *                             * */
  109. /* *************************************************** */
  110.  
  111. void main(long argc, char **argv)
  112. {
  113.  if(!argc) Leave(N, 0);
  114.  
  115.  if( argc > 3 || (argv[1][0] =='?')||(argv[2][0] =='?'))
  116.   {
  117.    K_Printf("%s%s%s", entry1_text, entry2_text, entry3_text);
  118.  
  119.    Leave(N, 0);
  120.   }
  121.  
  122.  IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37);
  123.  if(!IntuitionBase) Leave(intuitionlib_text, 100);
  124.  
  125.  SuperViewBase = (struct SuperViewBase *) OpenLibrary("superview.library", 5);
  126.  if(!SuperViewBase) Leave(svlib_text, 103);
  127.  
  128.  SVSupportBase = (struct SVSupportBase *) OpenLibrary("superviewsupport.library", 2);
  129.  if(!SVSupportBase) Leave(svslib_text, 103);
  130.  
  131.  Load_Test();
  132.  
  133.  Leave("\n", 0);
  134. }
  135.  
  136. void __regargs Load_Test(void)
  137. {
  138.  struct SV_ControlPad *pad;
  139.  struct SV_ControlPad *fpad;
  140.  
  141.  K_Printf("\nTesting LOADING of ControlPads (from PAD)");
  142.  
  143.  if(SVSUP_LoadControlPad("PAD", &pad))
  144.   {
  145.    fpad = pad;
  146.  
  147.    while(pad)
  148.     {
  149.      if(pad->svc_EntryContent) K_Printf("\nContent : \42%s\42=\42%s\42", pad->svc_EntryName, pad->svc_EntryContent);
  150.       else                     K_Printf("\nContent : \42%s\42", pad->svc_EntryName);
  151.  
  152.      pad = pad->svc_NextEntry;
  153.     }
  154.  
  155.    if(fpad)
  156.     {
  157.      char *content;
  158.  
  159.      K_Printf("\n\nIs there a ControlPad called TEST_PAD ?");
  160.  
  161.      if(SVSUP_FindControlPad(fpad, "TEST_PAD", &content))
  162.       {
  163.        if(content) K_Printf("\nIts Content is \42%s\42 !", content);
  164.         else       K_Printf("\nIt has no content !");
  165.  
  166.       }else K_Printf("\n No, actually not.");
  167.  
  168.  
  169.      K_Printf("\n\n*** OK, testing SAVING of ControlPads (to NEWPAD)");
  170.  
  171.      Save_Test(fpad);
  172.  
  173.      SVSUP_FreeControlPad(fpad);
  174.     }
  175.  
  176.   }else Leave("Can't open Test-File \42PAD\42 !", 10);
  177. }
  178.  
  179. void __regargs Save_Test(struct SV_ControlPad *pad)
  180. {
  181.  if(SVSUP_SaveControlPad("NEWPAD", pad)) K_Printf("\n*** OK, now compare the two files : \n*** All comments should be missing in NEWPAD.");
  182.   else                                   K_Printf("\n*** Can't write to NEWPAD.");
  183. }
  184.  
  185. /* *************************************************** */
  186. /* *                             * */
  187. /* * LEAVE : Global Exit Function Replacement         * */
  188. /* *                             * */
  189. /* *************************************************** */
  190.  
  191. void __regargs Leave(char *endtext, long code)
  192. {
  193.  if(SVSupportBase) CloseLibrary((APTR) SVSupportBase);
  194.  if(SuperViewBase) CloseLibrary((APTR) SuperViewBase);
  195.  if(IntuitionBase) CloseLibrary((APTR) IntuitionBase);
  196.  
  197.  if(endtext)       K_Printf("%s\n", endtext);
  198.  
  199.  exit(code);
  200. }
  201.